home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE15 / CONSTRUC / CONVERT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-10-07  |  1.5 KB  |  56 lines

  1. {$APPTYPE CONSOLE}
  2. uses DB, DBTables, SysUtils;
  3.  
  4. Type
  5.   TRecord = record
  6.     ISBN: String[16];
  7.     Title: String[64];
  8.     Author: String[64];
  9.     Publisher: String[32];
  10.     Price: Double;
  11.     Code: String[7];
  12.     { Comments }
  13.     Level: Integer;
  14.     TechnicalContentsQuality: Integer;
  15.     QualityOfWriting: Integer;
  16.     ValueForMoney: Integer;
  17.     OverallAssessment: Integer;
  18.     { Cover }
  19.   end;
  20.  
  21. var i: Integer;
  22.     Rec: TRecord;
  23.     F: File of TRecord;
  24. begin
  25.   if ParamCount >= 1 then with TTable.Create(nil) do
  26.   try
  27.     System.Assign(f,ChangeFileExt(ParamStr(1),'.REC'));
  28.     Rewrite(f);
  29.     TableName := ParamStr(1);
  30.     Active := True;
  31.     First;
  32.     while not Eof do with Rec do
  33.     begin
  34.       ISBN := FieldByName('ISBN').AsString;
  35.       Title := FieldByName('Title').AsString;
  36.       Author := FieldByName('Author').AsString;
  37.       Publisher := FieldByName('Publisher').AsString;
  38.       Price := FieldByName('Price').AsFloat;
  39.       Code := FieldByName('Code').AsString;
  40.       Level := FieldByName('Level').AsInteger;
  41.       TechnicalContentsQuality :=
  42.         FieldByName('TechnicalContentsQuality').AsInteger;
  43.       QualityOfWriting := FieldByName('QualityOfWriting').AsInteger;
  44.       ValueForMoney := FieldByName('ValueForMoney').AsInteger;
  45.       OverallAssessment := FieldByName('OverallAssessment').AsInteger;
  46.       write(f,Rec);
  47.       Next
  48.     end
  49.   finally
  50.     System.Close(f);
  51.     Free
  52.   end
  53.   else
  54.     writeln('Usage: convert tablename')
  55. end.
  56.